/*
 * TMessageBox.h
 *
 *  Created on: 2011-6-3
 *      Author: Jeff
 */

#ifndef TMessageBox_H_
#define TMessageBox_H_

#include "TSkinDialog.h"
#include <QMessageBox>
#include <QHBoxLayout>
#include <QPushButton>
#include <QHash>
#include <QLabel>

class TMessageBox
  : public TSkinDialog
{
    Q_OBJECT

public:
    TMessageBox(QWidget* parent = 0);
    explicit TMessageBox(const QString& title, const QString& text,
    QMessageBox::StandardButtons buttons = QMessageBox::NoButton,
    QMessageBox::StandardButton defaultButton = QMessageBox::NoButton,
    QWidget* parent = 0);

public:
    QMessageBox::StandardButton getResult() const
    {
        return _result;
    }

protected slots:
  void buttonClicked();

protected:
  void keyPressEvent(QKeyEvent* e);

private:
  QPushButton* getButton(QMessageBox::StandardButton which) const;
  QMessageBox::StandardButton standardButton(QPushButton* button) const;
  void createStandardButtons(QHBoxLayout* buttonsLayout,
  QMessageBox::StandardButtons buttons);
  QPushButton* createButton(QMessageBox::StandardButton sbutton);
  QString standardButtonText(QMessageBox::StandardButton sbutton) const;

private:
  QHash<QPushButton*, QMessageBox::StandardButton> _standardButtonHash;
  QMessageBox::StandardButton _result;

  QLabel* _pic;
};
#endif /* TMessageBox_H_ */
